<template>
<el-row :gutter="10">
    <el-col :span="24">
        <el-table ref="singleTable" :data="absenceList" border stripe style="width: 100%" height="460">
            <el-table-column label="序号" type="index" width="50">
            </el-table-column>
            <el-table-column property="ename" label="请假人" width="100" align="center">
            </el-table-column>
            <el-table-column align="center" property="dname" label="所属部门" width="150">
            </el-table-column>
            <el-table-column align="center" property="absenceType" label="请假类型" width="120">
            </el-table-column>
            <el-table-column align="center" property="startTime" label="开始时间" width="200">
            </el-table-column>
            <el-table-column align="center" property="planEndTime" label="请假结束时间" width="200">
            </el-table-column>
            <el-table-column align="center" property="planDays" label="计划请假时长" width="120">
            </el-table-column>
            <el-table-column align="center" property="realEndTime" label="实际销假时间" width="200" v-if="!isAudit">
                <template slot-scope="scope">
                    {{ realEndTimeMapper(scope.row.realEndTime) }}
                </template>
            </el-table-column>
            <el-table-column align="center" property="realDays" label="实际请假时长" width="120" v-if="!isAudit">
                <template slot-scope="scope">
                    {{ realDaysMapper(scope.row.realDays) }}
                </template>
            </el-table-column>
            <el-table-column align="center" property="stageStr" label="状态" width="120" fixed="right">
                <template slot-scope="scope">
                    {{ finishMap(scope.row) }}
                </template>
            </el-table-column>
            <el-table-column align="center" fixed="right" label="操作" width="150">
                <template slot-scope="scope">
                    <el-button @click="handleView(scope.row)" type="text" size="small">查看</el-button>
                    <el-button @click="handleDel(scope.row)" type="text" size="small" v-if="!isAudit">删除</el-button>
                    <el-button @click="handleStep(scope.row)" type="text" size="small" v-if="!isAudit">流程图</el-button>
                </template>
            </el-table-column>
        </el-table>

    </el-col>
</el-row>
</template>

<script>

export default {
    name:'AbsenceTable',
    props:{
        absenceList:Array,
        isAudit:Boolean,
    },
    date(){
        return{
            isTrue:true,
        }
    },
    methods:{
        handleView(row){
            this.$emit('view',row)
        },
        handleDel(row){
            this.$emit('del',row)
        },
        handleStep(row){
            this.$emit('steps',row)
        },
        realEndTimeMapper(realEndTime){
            if(realEndTime == null) {
                return '暂未销假'
            } else {
                return realEndTime
            }
        },
        realDaysMapper(realDays){
            if(realDays == '0') {
                return '暂未销假'
            } else {
                return realDays
            }
        },
        finishMap(row){
            if(row.stage == '3' && row.realDays == '0') {
                return '未销假'
            } else if(row.realDays != '0') {
                return '已销假'
            } else {
                return row.stageStr
            }
        }
        
    }

}
</script>

<style>

</style>
